<template>
	<view class="fui-wrap">
		<fui-list>
			<fui-list-cell v-for="(item,index) in list" :key="index" :highlight="false">
				<view class="item">
					<view class="line">
						<fui-text text="时间：" color="#afafaf" :size="28"></fui-text>
						<fui-text :text="item.date" color="black" :size="28"></fui-text>
					</view>
					<view class="line-between">
						<view class="one">
							<fui-text text="停车支付：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.parking_income)" color="black" :size="28"></fui-text>
						</view>
						<view class="one">
							<fui-text text="月卡充值：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.parking_monthly_income)" color="black" :size="28"></fui-text>
						</view>
					</view>
					<view class="line-between">
						<view class="one">
							<fui-text text="储值卡充值：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.parking_stored_income)" color="black" :size="28"></fui-text>
						</view>
						<view class="one">
							<fui-text text="商户充值：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.merch_recharge_income)" color="black" :size="28"></fui-text>
						</view>
					</view>
					<view class="line-between">
						<view class="one">
							<fui-text text="日退款：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.total_refund)" color="black" :size="28"></fui-text>
						</view>
						<view class="one">
							<fui-text text="日手续费：" color="#afafaf" :size="28"></fui-text>
							<fui-text :text="'￥'+parseNumber(item.handling_fees)" color="black" :size="28"></fui-text>
						</view>
					</view>
					<view class="line-between" style="margin-bottom: 0;">
						<view class="one">
							<fui-text text="日收益：" color="#afafaf" :size="28"></fui-text>
							<fui-text v-if="item.total_income>=0" :text="'￥'+parseNumber(item.total_income)" color="black" :size="28"></fui-text>
							<fui-text v-else :text="'-￥'+parseNumber(-item.total_income)" color="black" :size="28"></fui-text>
						</view>
						<view class="one">
							<fui-text text="日结算：" color="#afafaf" :size="28"></fui-text>
							<fui-text v-if="item.net_income>=0" :text="'￥'+parseNumber(item.net_income)" color="green" :size="28"></fui-text>
							<fui-text v-else :text="'-￥'+parseNumber(-item.net_income)" color="red" :size="28"></fui-text>
						</view>
					</view>
				</view>
			</fui-list-cell>
		</fui-list>
		<fui-empty v-if="list.length===0" :src="`${baseUrl}assets/img/miniapp/empty.png`" title="暂无数据!" :marginTop="200"></fui-empty>
		<filter :param="param" @confirm="doSubmit"></filter>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	import {parseNumber} from '@/utils/util.js'
	import filter from '@/components/common/filter.vue';
	export default {
		components:{
			filter:filter
		},
		data() {
			return {
				baseUrl:baseUrl,
				list:[],
				page:1,
				endData:false,
				param:{
					starttime:'',
					endtime:''
				}
			}
		},
		onLoad(e) {
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		onPullDownRefresh() {
			this.list=[];
			this.page=1;
			this.endData=false;
			this.getList(function(){
				uni.stopPullDownRefresh();
			});
		},
		methods: {
			...methods,
			parseNumber,
			doSubmit:function(param){
				this.param=param;
				this.list=[];
				this.page=1;
				this.endData=false;
				this.getList();
			},
			getList:function(callback=false){
				this.showPopup=false;
				if(this.endData){
					this.$msg('已经到底了');
					return;
				}
				this.$get('parking/finance/settle',{
					...this.param,
					page:this.page
				},true).then(res=>{
					this.list=this.list.concat(res);
					this.page++;
					if(res.length<10){
						this.endData=true;
					}	
					if(callback){
						callback();
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.item{
	display: flex;
	flex-wrap: wrap;
	width:100%;
	.line{
		display: flex;
		align-items: center;
		width:100%;
		margin-bottom: 10rpx;
	}
	.line-between{
		display: flex;
		align-items: center;
		justify-content: space-between;
		width:100%;
		margin-bottom: 10rpx;
		.one{
			display: flex;
			align-items: center;
			width: 50%;
		}
	}
}
</style>